function equalPasswords() {

	var pwd1 = document.getElementById('pass1');
	var pwd2 = document.getElementById('pass2');
	if(pwd1.value != pwd2.value) {
		alert('Passwords do not match. Please retry.');
		return false;
	}
	return true;	
}

function isValidEmail(strEmail) {
	
	  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	  strEmail = document.getElementById('email').value;
	  
	   // search email text for regular exp matches
	  if (strEmail.search(validRegExp) == -1) {
		  alert('A valid e-mail address is required. Please retry.');
		  return false;
	  } 
	  return true; 
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g, '') ;
}

function emptyFields() {
	
	var pwd1 = document.getElementById('pass1').value;
	var pwd2 = document.getElementById('pass2').value;
	var login = document.getElementById('login').value;
	if ((trim(pwd1) == "") || (trim(pwd2) == "") || (trim(login) == "")) {
		alert('All fields are required.');
		return true;
	}
	return false;	
}

function validateRegForm() {
	
	return !emptyFields() && isValidEmail() && equalPasswords();
}

